Fix MOK enrollment failure: hardcoded shebang and shell parameter passing#147
Fix MOK enrollment failure: hardcoded shebang and shell parameter passing#147
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
361e1ce to
715bc2b
Compare
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 715bc2bc83
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| task secure-mok-new | ||
| describe Generate new PhoenixGuard MOK keypair (use NAME and CN env) | ||
| shell bash -lc 'scripts/mok-management/mok-new.sh "${NAME:-PGMOK}" "${CN:-PhoenixGuard Module Key}"' | ||
| shell bash scripts/mok-management/mok-new.sh "${NAME:-PGMOK}" "${CN:-PhoenixGuard Module Key}" |
There was a problem hiding this comment.
Preserve quoting for default CN passed to mok-new
This invocation relies on quoted parameter expansion for "${CN:-PhoenixGuard Module Key}", but the pf runner tokenizes shell commands and rebuilds them as a space-joined string, so the quotes are dropped before execution; the default expands unquoted and is split into multiple words. As a result, scripts/mok-management/mok-new.sh receives CN as only PhoenixGuard (with Module/Key as extra args), which silently changes the generated certificate subject. The same pattern also appears in secure.pf (secure-mok-enroll-new).
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| task secure-mok-new | ||
| describe Generate new PhoenixGuard MOK keypair (use NAME and CN env) | ||
| shell bash -lc 'scripts/mok-management/mok-new.sh "${NAME:-PGMOK}" "${CN:-PhoenixGuard Module Key}"' | ||
| shell bash scripts/mok-management/mok-new.sh "${NAME:-PGMOK}" "${CN:-PhoenixGuard Module Key}" |
There was a problem hiding this comment.
Spaces in CN default value cause word-splitting
Medium Severity
The pf tool's parser strips quotes during tokenization (evidenced by .pf_fix.py needing shlex.quote() to re-add them for -c/-lc args). For the new non--lc pattern, "${CN:-PhoenixGuard Module Key}" loses its double quotes after parse-and-rejoin via " ".join(args). When CN is unset, the default value PhoenixGuard Module Key gets word-split into three arguments. mok-new.sh then receives $2 as PhoenixGuard instead of PhoenixGuard Module Key, generating a certificate with an incorrect Common Name.


Description
MOK enrollment tasks failed with
ModuleNotFoundError: No module named 'fabric'when invoked viaphoenixboot-wizard.shor directly. Root causes:#!/home/punk/.venv/bin/python(user-specific venv path)bash -lc 'script.sh "$VAR"'expanded variables in subshell but scripts expected positional parameters$1,$2,$3Changes
#!/usr/bin/env python3for portabilityos-mok-enroll,secure-mok-newsecure-mok-verify,secure-enroll-mok,secure-mok-enroll-new,secure-unenroll-mok,secure-der-extractBefore:
shell bash -lc 'scripts/mok-management/enroll-mok.sh "${VAR1}" "${VAR2}" ${VAR3}'After:
How This Was Tested
Verified all MOK tasks execute and reach target scripts with correct parameters:
./pf.py os-mok-enroll- Reaches UEFI firmware check./pf.py secure-mok-new- Generates keys successfully./pf.py list- Shows all tasks correctlyphoenixboot-wizard.sh- Advanced menu option 3 (Enroll MOK) executesIntegration Instructions
N/A - Bug fix with no integration requirements.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.
Note
Low Risk
Low risk: changes are limited to task wrappers, switching from
bash -lcto direct script invocation to ensure positional arguments are passed correctly.Overview
Fixes several
.pftask definitions to call MOK/secure-boot helper scripts directly (instead of viabash -lc), ensuring environment-provided values are passed as proper positional parameters and consistently quoted (notablyMOK_DRY_RUN).This updates the enrollment/verification/new-key/unenroll/DER-extract workflows in
core.pfandsecure.pf, and removes a stray trailing line incore.pf.Written by Cursor Bugbot for commit 715bc2b. Configure here.